// 系统管理使用的接口
import {apiRequestList} from "@/common/axios"
import tool from "@/common/tool.js"
let userMess = tool.getStorage("userMess"), mess = JSON.parse(userMess),{appId,userId} = mess;

const departmentTree = '/dt-business/bg/org/tree',//部门列表
      departmentAdd = '/dt-business/bg/aggs/org/create',//部门新增
      departmentUpdate = '/dt-business/bg/org/update',//部门修改名字
      peopleList = '/dt-business/user/aggs/user/manage/list',//用户列表
      peopleAdd = '/dt-business/user/aggs/user/create', //用户新增
      peopleDelete = '/dt-business/user/aggs/user/delete', //用户删除
      roleList = '/dt-business/bg/role/page',//角色列表
      roleAdd = "/dt-business/bg/role/create",//角色增加
      roleUpdate = '/dt-business/bg/role/update',//角色更新
      roleDelete = '/dt-business/bg/role/delete',//角色删除
      treeList = '/dt-business/role/permission/getTree',//获取权限列表
      treeUpdate = '/dt-business/bg/role/permission/update'//更新权限列表

export const getDepartmentTree = (params={})=>{
    params = Object.assign(params,{appId:appId ,userId})
    return apiRequestList.$post(departmentTree,params)
}
export const getDepartmentAdd = (params)=>{
    params = Object.assign(params,{appId:appId , createrId:userId,})
    return apiRequestList.$post(departmentAdd,params)
}
export const getDepartmentUpdate = (params)=>{
    params = Object.assign(params,{appId:appId ,updaterId:userId,})
    return apiRequestList.$post(departmentUpdate,params)
}
export const getpeopleList = (params)=>{
    params = Object.assign(params,{appId:appId ,userId,})
    return apiRequestList.$post(peopleList,params)
}
export const getPeopleAdd = (params)=>{
    params = Object.assign(params,{appId,createrId:userId})
    return apiRequestList.$post(peopleAdd,params)
}
export const getPeopleDelete = (params)=>{
    params = Object.assign(params,{appId:appId ,userId,})
    return apiRequestList.$post(peopleDelete,params)
}
export const getRoleList = (params={})=>{
    params = Object.assign(params,{appId:appId })
    return apiRequestList.$post(roleList,params)
}
export const getRoleAdd = (params)=>{
    params = Object.assign(params,{appId:appId ,createrId:userId})
    return apiRequestList.$post(roleAdd,params)
}
export const getRoleUpdate = (params)=>{
    params = Object.assign(params,{appId:appId ,updaterId: userId})
    return apiRequestList.$post(roleUpdate,params)
}
export const getRoleDelete = (params)=>{
    params = Object.assign(params,{appId:appId ,userId,})
    return apiRequestList.$post(roleDelete,params)
}
export const getTreeList = (params)=>{
   return apiRequestList.$post(treeList,params);
}
export const getTreeUpdate = (params)=>{
    params = Object.assign(params,{appId:appId })
    return apiRequestList.$post(treeUpdate,params)
}
//部门删除
export const getDepartmentDelete = (params={})=>apiRequestList.$post('/dt-business/bg/org/update', Object.assign(params,{appId:appId,updaterId:userId}))
//变更部门
export const getDepartmentChange = (params={})=>apiRequestList.$post('/dt-business/user/aggs/user/update/permission', Object.assign(params,{appId:appId,updaterId:userId}))
//用户禁用
export const getUserDisabled = (params={})=>apiRequestList.$post('/dt-business/user/update', Object.assign(params,{appId:appId,updaterId:userId}))
